function compareVersion(version1,version2){
    const v1 = version1.split('.')
    const v2 = version2.split('.')
    const maxLen = Math.max(v1.length, v2.length)
    
    // 补齐较短的版本号数组
    while (v1.length < maxLen) v1.push('0')
    while (v2.length < maxLen) v2.push('0')
    
    for(let i = 0; i < maxLen; i++){
        const num1 = parseInt(v1[i], 10)
        const num2 = parseInt(v2[i], 10)
        
        if(num1 > num2){
            return true   // version1 > version2
        }else if(num1 < num2){
            return false  // version1 < version2
        }
        // 如果相等，继续比较下一个部分
    }

    return false  // version1 == version2
}

// 测试用例
console.log('======= 版本号比较测试 =======')

// 测试用例1: 基本版本号比较
console.log('测试1 - 基本版本号:')
console.log(`compareVersion("1.0.0", "1.0.1"): ${compareVersion("1.0.0", "1.0.1")}`) // false
console.log(`compareVersion("1.0.1", "1.0.0"): ${compareVersion("1.0.1", "1.0.0")}`) // true
console.log(`compareVersion("1.0.0", "1.0.0"): ${compareVersion("1.0.0", "1.0.0")}`) // false

// 测试用例2: 不同长度版本号比较
console.log('\n测试2 - 不同长度版本号:')
console.log(`compareVersion("1.0", "1.0.0"): ${compareVersion("1.0", "1.0.0")}`)     // false
console.log(`compareVersion("1.0.0", "1.0"): ${compareVersion("1.0.0", "1.0")}`)     // false
console.log(`compareVersion("1.0.1", "1.0"): ${compareVersion("1.0.1", "1.0")}`)     // true
console.log(`compareVersion("1.0", "1.0.1"): ${compareVersion("1.0", "1.0.1")}`)     // false

// 测试用例3: 多段版本号比较
console.log('\n测试3 - 多段版本号:')
console.log(`compareVersion("2.1.3", "2.1.2"): ${compareVersion("2.1.3", "2.1.2")}`) // true
console.log(`compareVersion("2.1.2", "2.1.3"): ${compareVersion("2.1.2", "2.1.3")}`) // false
console.log(`compareVersion("2.1.3", "2.1.3"): ${compareVersion("2.1.3", "2.1.3")}`) // false

// 测试用例4: 包含两位数的版本号
console.log('\n测试4 - 包含两位数的版本号:')
console.log(`compareVersion("1.10.0", "1.2.0"): ${compareVersion("1.10.0", "1.2.0")}`) // true
console.log(`compareVersion("1.2.0", "1.10.0"): ${compareVersion("1.2.0", "1.10.0")}`) // false

// 测试用例5: 边界情况
console.log('\n测试5 - 边界情况:')
console.log(`compareVersion("0.0.0", "0.0.1"): ${compareVersion("0.0.0", "0.0.1")}`) // false
console.log(`compareVersion("10.0.0", "2.0.0"): ${compareVersion("10.0.0", "2.0.0")}`) // true